Threading bug

Revision 12827 - 2021-01-19

The issue with disappearing ViewModel columns debug Fixed.

This was really InAsyncThreadOrTheMainThreadInNonAsyncAppSoYouCanNeverGiveUp that sometimes was left to false for some parallel threads doing the file write. This led to Enumerations that ran into longer locks and gave up, returning fewer results than they had - and this led to how file write wrote incomplete data.

The reason for the Enumerations' ability to give up is UI. UI continues in an Async app and trusts that the Async thread eventually brings the missing data.

  • This was probably also the issue behind the failing file saves from 2018 when it signaled failed and asked you to try again. This error was then wrongfully "fixed" leading to the much worse error of incomplete file writes (that is now fixed).

To ensure your application is NOT in any way suffering from giving up iterations of lists due to temporary locks, always set the InAsyncThreadOrTheMainThreadInNonAsyncAppSoYouCanNeverGiveUp like this:

AsyncServiceSupportThreadInfo.InAsyncThreadOrTheMainThreadInNonAsyncAppSoYouCanNeverGiveUp = true; // thread is no longer uninteruptable
public static class AsyncServiceSupportThreadInfo
{
  /// <summary>
  /// Will return true when called from a thread that is an active async-thread in an EcoSpace
  /// </summary>
  [ThreadStatic]
  public static bool InAsyncThreadOrTheMainThreadInNonAsyncAppSoYouCanNeverGiveUp = true; // in NonAsync apps - mainthread has same status as the async thread (un interuptable)
}
This page was edited 77 days ago on 02/10/2024. What links here